﻿#vertex_shader code
// 顶点着色器代码开始
#version 440 core
layout (location = 0) in vec4 position; // input a vertex position
layout (location = 1) in vec2 texCoord; // input a texture position

out vec2 v_TexToord;                    // output a texture position to the vertex shader
uniform mat4 m_MVP;                     // input a model-view-projection matrix

void main()
{
    gl_Position = m_MVP * position;     // set the position of the vertex，gl_Position is a built-in variable in OpenGL
    v_TexToord = texCoord;              // set the texture position of the vertex
}
// 顶点着色器代码结束

#fragment_shader code
// 片元着色器代码开始
#version 440 core
layout (location = 0) out vec4 color;   // output a color

in vec2 v_TexToord;                     // input a texture position from the vertex shader

uniform vec4 u_Color;                   // input a color from the vertex shader
uniform sampler2D u_Texture;            // input a texture from the vertex shader

void main()
{
    vec4 texColor = texture(u_Texture, v_TexToord); // sample the texture
    //color = texColor;                   // set the color of the fragment
    // color = u_Color;
    color = u_Color + texColor;
}
// 片元着色器代码结束